#include <iostream>
#include <cerrno>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <string>
#include <sys/stat.h>
#include <sys/ipc.h>
#include <sys/types.h>
#include <sys/shm.h>

using namespace std;

#define PATHNAME "."
#define PROJID 0x6666

const int gsize = 4096;

key_t getKey(){
    key_t k = ftok(PATHNAME, PROJID);
    return k;
}

string toHex(int x){
    char buffer[64];
    snprintf(buffer, sizeof(buffer), "0xj%x", x);
    return buffer;
}

static int createShmHelper(key_t k, int size, int flag){
    int shmid = shmget(k, gsize, flag);
    return shmid;
}